package com.gyt.manager.common.component;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * description.
 *
 * @author gyt create on 2021/5/10 14:34
 */
@Component
public class EnvComponent {

    private static final String ENV_DEV = "dev";
    private static final String ENV_TEST = "test";
    private static final String ENV_PROD = "prod";
    private static String profiles;
    @Autowired
    private Environment environment;

    @PostConstruct
    public void init() {
        profiles = environment.getProperty("spring.profiles.active");
    }

    public static boolean isDev() {
        return ENV_DEV.equals(profiles);
    }

    public static boolean isTest() {
        return ENV_TEST.equals(profiles);
    }

    public static boolean isProd() {
        return ENV_PROD.equals(profiles);
    }
}
